<?php

class Add_Item extends Controller {

    function Add_Item()
    {
            parent::Controller();
            $this->load->helper('admin');
            
            construct_admin_controller($this->EzAuth_Model);
	    
	    //form helper
		$this->load->helper('form');
            
            
    }
    
    function add_item_page() {
        $this->index();
    }
    
    //do something before we load the page:
    //check to see if you are logged in
    
    function _remap($method) {
        checkauth($this, $method, $this->EzAuth_Model);
    }
    
    function item_form()
    {
	$form = '';
        $form .=form_open_multipart('', array('id'=>'new_item'));
	
	//item barcode
	$form .=form_label('Product Barcode','barcode');
        $form .=form_input(array('name'=>'barcode', 'id'=>'barcode', 'size'=>'30'));
	$form .='<br />';
	
        //item title
	$form .=form_label('Product Name','title');
        $form .=form_input(array('name'=>'title', 'id'=>'title', 'size'=>'30'));
	
	$form .='<br />';
	
	//description
	$form .=form_label('Description','desc');
	$form .=form_textarea(array('name'=>'desc','id'=>'desc','cols'=>'30','rows'=>'6'));
	
	$form .='<br />';
	
	//image (only a url goes in DB)
	//let's say three options; from your computer, upload from a different website, previously uploaded.
        $form .='<span class="radio">';
	$form .=form_label('Upload from your computer', 'upload');
	$form .=form_radio(array('name'=>'pic_from','id'=>'upload'),'visible',TRUE);
        $form .='<br />';
	$form .=form_label('Upload from a URL', 'url');
	$form .=form_radio(array('name'=>'pic_from','id'=>'url'),'hidden',FALSE);
        $form .='</span>';
	
	$form .='<br />';
	
        $form .='<div id="from_COMP">';
	$form .=form_upload(array('size'=>'30'));
        $form .='</div>';
	
	$form .='<br />';
	
        
        $form .='<div id="from_URL">';
	$form .=form_input(array('value'=>'http://','name'=>'picture', 'id'=>'picture', 'size'=>'30'));
	$form .='</div>';
	$form .='<br />';
	
	//price
	$form .=form_label('Price', 'price');
	$form .='$';
	$form .=form_input(array('name'=>'price','id'=>'price', 'size'=>'15'));
	
	$form .='<br />';
	
	//date to post
	
	//visible or invisible?
	$form .=form_label('Hidden?', 'hidden');
	$form .=form_checkbox(array('name'=>'visibility','id'=>'hidden'),'hidden',FALSE);        
        
        $form .='<br />';
        $form .='<br />';
        
        $form .=form_submit('submit','List');
        
        $form .=form_submit('preview','Preview');
	
        $form.='</form>';
	
	return $form;
        
    }
    
    function index()
    {
        $data = get_page_ready('add_item',0, $this->Settings_Model, $this->Pages_Model, $this->Products_Model, $this->Categories_Model);
        
	$data['form'] = $this->item_form();
         
        $data['location'] = 'add_item';
        $this->load->view('admin/add_item', $data);
    }	

}
?>